import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 引入icon
import 'virtual:svg-icons-register'
import SvgIcon from './components/SvgIcon/index.vue';
import elementIcons from './assets/icons';

// 引入登录
import Login from './components/Login/index.vue';
// 引入表格模块
import table from './components/Table/index.vue';
// 柱状图
import bar from './components/Bar/index.vue'
// 饼图
import pie from './components/Pie/index.vue'
// 折线图
import line from './components/Line/index.vue'
// 热力图
import heatmap from './components/Heatmap/index.vue'
// 散点图
import scatter from './components/Scatter/index.vue'
import TooltipView from '@/components/TooltipView/index.vue'

// 引入公共样式
import '@/assets/css/index.css'
import '@/assets/css/container.scss'


// //使用钩子函数对路由进行权限跳转
// router.beforeEach((to, from, next) => {
//     const role = sessionStorage.getItem('token');
//     if (!role && to.name !== 'Login') {
//         next('/pages/login');
//     } else if (to.meta.permission) {
//         // 如果是管理员权限则可进入，这里只是简单的模拟管理员权限而已
//         role === 'template' ? next() : next('/pages/login');
//     } else {
//         next();
//     }
// })
const app = createApp(App);
// 状态管理
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
app.use(elementIcons)
app.component('svg-icon', SvgIcon)
// 登录界面
// app.use(Login)
app.component('login', Login)
// 表格
// app.use(table)
app.component('robot-table', table)
// 柱状图
// app.use(bar)
app.component('robot-bar', bar)
// 饼图
// app.use(pie)
app.component('robot-pie', pie)
// 折线图
// app.use(line)
app.component('robot-line', line)
// 热力图
// app.use(heatmap)
app.component('robot-heatmap', heatmap)
// 散点图
// app.use(scatter)
app.component('robot-scatter', scatter)
app.component('TooltipView', TooltipView)


app.use(ElementPlus).use(router).use(pinia).mount('#app')
